package com.ruoyi.project.custom.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.custom.domain.CustomFollow;
import com.ruoyi.project.custom.domain.vo.CustomFollowVo;
import com.ruoyi.project.custom.service.ICustomFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/custom/follow")
public class CustomFollowController extends BaseController {
    @Autowired
    private ICustomFollowService followService;

    @GetMapping("/list/{customId}")
    public AjaxResult list(@PathVariable("customId") String customId){
        return AjaxResult.success(followService.selectCustomFollowList(customId));
    }

    @GetMapping("/selectFollowList")
    public TableDataInfo selectFollowList(CustomFollowVo followVo){
        startPage();
        List<CustomFollowVo> list =  followService.selectFollowList(followVo);
        return getDataTable(list);
    }

    @PostMapping("")
    public AjaxResult insertCommunication(@RequestBody CustomFollow follow){
        return toAjax(followService.insertCustomFollow(follow));
    }

    @PutMapping("")
    public AjaxResult updateCommunication(@RequestBody CustomFollow follow){
        return toAjax(followService.updateCustomFollow(follow));
    }

    @DeleteMapping("/{id}")
    public AjaxResult deleteCommunication(@PathVariable("id") int id){
        return toAjax(followService.deleteCustomFollow(id));
    }
}
